home *** CD-ROM | disk | FTP | other *** search
- connect "C:\DDS\CHAP08\CSHOWTO.GDB"
- user "SYSDBA" password "masterkey";
-
-
- /*****************************************************************
- Create sample table
- */
-
- Create Table BookTable
- (
- BookId smallint not null,
- Title varchar( 30 ),
- Authors varchar( 30 ),
- Primary Key( BookId )
- );
-
- COMMIT;
-
- /*****************************************************************
- Create key generator for sample table
- */
-
- Create Generator BookGenerator;
- Set Generator BookGenerator to 0;
-
- COMMIT;
-
- /*****************************************************************
- Create stored procedure for sample table
- */
-
- Set Term ! ;
-
- Create Procedure NewBookIdProcedure
- Returns ( TheNewBookId Integer )
- As
- begin
- TheNewBookId = Gen_Id( BookGenerator, 1 );
- end !
-
- Set Term ; !
-
- COMMIT;
-
- /*****************************************************************
- Create trigger for sample table
- */
-
- Set Term ! ;
-
- Create Trigger BookTableBerforeInsert
- For BookTable
- Before Insert
- As
- begin
- if ( New.BookId is Null ) then
- begin
- Execute procedure NewBookIdProcedure
- Returning_Values New.BookId;
- end
- end !
-
- Set Term ; !
-
- COMMIT;
-